home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 3.1 KB | 68 lines | [TEXT/GEOL] |
- Item 9603562 31-March-88 14:36
-
- From: ROSENSTEIN1 Rosenstein, Larry
-
- To: MACAPP$ MacApp Interest List
-
- Sub: Save as Text in MacApp
-
- When we designed the MacApp saving code, we explicitly thought about the
- problem of saving as different file types. It is easy to do, although not well
- documented. The following should give you an idea of how to implement this.
- There are several options depending on the exact behavior you want.
-
- First, if you want to add radio buttons to your save dialog, you override
- TDocument.SFPutParms. This method is supposed to return all the parameters for
- a call to SFPPutDialog (see Inside Mac). In this case, you want to change the
- dialog ID -- to specify a dialog with the radio buttons -- and pass a dialog
- filter proc to handle the radio buttons.
-
- (The equivalent method for the open dialog is TApplication.SFGetParms, and the
- UStationery unit on the MacApp developers disk shows how to modify the open
- dialog.)
-
- You should save in a new TDocument field the desired file format as chosen by
- the user. (I don't advice saving this information in the fFileType field of
- TDocument, because if the save is cancelled, you will have to restore the
- original value.)
-
- The next method to look at is TDocument.AboutToSave. You need to override this
- method if you want to implement the MacWrite style of saving. You'll notice in
- MacWrite that saving a text-only copy of the document doesn't change the name
- of the window and only saves a copy of the document. If you wanted to do the
- same thing, you would override AboutToSave and change the makingCopy parameter
- to TRUE.
-
- MacDraw, however, does it differently. If you save as a PICT file, then
- subsequent saves for that document also save as a PICT file. In this case, you
- don't need to override AboutToSave.
-
- The next method to look at is TDocument.GetSaveInfo. This method is supposed
- to fill up a File Manager parameter block with the necessary information for
- the resulting file. In this case, you look at the file type you want to save
- as, and put the desired 4-character type ID in the parameter block.
-
- Your DoWrite method can look at the desired file type to determine how to save
- the file.
-
- Finally, you need to override the method TDocument.SavedOn. This gets called
- if you successfully save a document. It normally does things like change the
- window title(s) in the case of a Save As... command. You should override this
- and set the document's fFileType field to the type you just saved as.
-
- This method won't be called if you changed makingCopy to TRUE in AboutToSave,
- and shouldn't have to be overridden if you always save into a copy (as in
- MacWrite).
-
- Also, notice that your DoRead method should look at the fFileType field to
- determine how to read the file in the case of a Revert.
-
- The important thing to remember is that you have to distinguish the type of the
- file that is currently on the disk (needed in the case of a Revert) from the
- type of the file you are trying to save as. These types might be different,
- and don't become the same until the SavedOn method is called.
-
- Larry
-
-
-